package pl.leader100.rest;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import pl.leader100.rest.data.Doc;
import pl.leader100.rest.data.DocDao;

public class ListDocByCat  {
	@Context
	UriInfo uriInfo;
	@Context
	Request request;

	String role;
	String date;
	String locale;
	String year = "2011/2012";
	String course = "junior_leader_r1";
	String category;

	public ListDocByCat(UriInfo uriInfo, Request request, String role,
			String date, String locale, String year, String course,
			String category) {
		this.uriInfo = uriInfo;
		this.request = request;
		this.role = role;
		this.date = date;
		this.locale = locale;
		this.year = year;
		this.course = course;
		this.category = category;
	}

	// Application integration
	@GET
	@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public List<Doc> getDocByCat() {
		List<Doc> docs = DocDao.GetInstance().getDocsByCat(role, date, locale,
				year, course, category);
		if (docs == null)
			throw new RuntimeException("Get: Doc with " + role + " " + date
					+ " " + locale + " not found");
		return docs;
	}
	
}
